package customer.core.internal;

import java.io.File;
import java.io.FilenameFilter;


public class CustomFileFilter implements FilenameFilter {

	private String extension = "";
	private boolean acceptDirs = false;
	
	public CustomFileFilter(String extension, boolean shouldAcceptDirs)
	{
		this.extension = extension;
		this.acceptDirs = shouldAcceptDirs;
	}
	
	public boolean accept(File dir, String name) {
		File f = new File(dir + File.separator + name);

		if(extension.equals("*") && !f.isDirectory())
			return true;
			
		if(name.endsWith(extension))
			return true;
		
		if(acceptDirs && f.isDirectory())
			return true;
		return false;
	}


}
